//
// Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
//
// GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
//  Author: Shawn.Tan
//  Date : 2025.10.28
//
//  History : Initial Version 2025.10.28
//
//
#include "UtilityAlgorithms.h"

#include "Constraint.h"
#include "Log.h"

using namespace std;

namespace Green {

  RandomSampler::RandomSampler(uint64 min, uint64 max)
    : mpConstraint(nullptr)
  {
    mpConstraint = new ConstraintSet(min, max);

  }

  RandomSampler::RandomSampler(const RandomSampler& rOther)
    : mpConstraint(nullptr)
  {
    LOG(fail) << "{RandomSampler::RandomSampler} copy constructor not expected to be called." << endl;
    FAIL("copy-constructor-not-expected-to-be-called");
  }

  RandomSampler::~RandomSampler()
  {
    delete mpConstraint;
  }

  uint64 RandomSampler::Sample()
  {
    if (mpConstraint->IsEmpty()) {
      return 0;
    }

    uint64 val = mpConstraint->ChooseValue();
    mpConstraint->SubValue(val);
    return val;
  }

}
